package com.tom.socket;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SocketChannel;
import java.nio.charset.StandardCharsets;

/**
 * @author zx
 * @date 2024-09-27 20:30
 */
public class MyClient {
    public static void main(String[] args) throws IOException {
        SocketChannel socketChannel = SocketChannel.open();
        socketChannel.connect(new InetSocketAddress(8000));
        System.out.println("-------------------------------");

        //向服务端发送信息
        int helloWorld = socketChannel.write(StandardCharsets.UTF_8.encode("你好!!!"));
        System.out.println("发送的字节数："+helloWorld);


    }
}
